﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using visinia.SmartEngine.Log;

public partial class Admin_Controls_Log : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LiteralControl menu = new LiteralControl(Render());
        Controls.Add(menu);
    }

    private string Render()
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<ul class=\"log-bar\">");
        Bind(sb);
        sb.Append("</ul>");
        return sb.ToString();
    }

    private void Bind(StringBuilder sb)
    {
        List<Activity> log = LogController.GetLog();
        foreach (Activity activity in log)
        {
            sb.Append("<li><p>" + activity.User + " " + Server.HtmlEncode(activity.Message) + "</p></li>");            
        }
    }
}
